home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume25 / fsp / part01 next >
Encoding:
Internet Message Format  |  1991-12-13  |  70.5 KB

  1. Subject: v25i024: A real-time, multithreaded Internet archive server, Part01/03
  2. Newsgroups: comp.sources.unix
  3. Approved: vixie@pa.dec.com
  4.  
  5. Submitted-By: wen-king@vlsi.cs.caltech.edu
  6. Posting-Number: Volume 25, Issue 24
  7. Archive-Name: fsp/part01
  8.  
  9. #! /bin/sh
  10. # This is a shell archive.  Remove anything before this line, then unpack
  11. # it by saving it into a file and typing "sh file".  To overwrite existing
  12. # files, type "sh file -c".  You can also feed this as standard input via
  13. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  14. # will see the following message at the end:
  15. #        "End of archive 1 (of 3)."
  16. # Contents:  MANIFEST README bsd_src bsd_src/Makefile bsd_src/cmp.c
  17. #   bsd_src/ls.h bsd_src/tweak.h bsd_src/util.c client_def.h
  18. #   client_lib.c fcatcmd.1 fcatcmd.c fcdcmd.1 fcdcmd.c fgetcmd.1
  19. #   fgetcmd.c flscmd.1 flscmd.c fmkdir.1 fmkdir.c fprocmd.1 fprocmd.c
  20. #   fput.1 fput.c frmcmd.1 frmcmd.c frmdircmd.1 frmdircmd.c fspd.1
  21. #   fver.1 fver.c server_def.h setup
  22. # Wrapped by vixie@cognition.pa.dec.com on Fri Dec 13 17:53:11 1991
  23. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  24. if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  25.   echo shar: Will not clobber existing file \"'MANIFEST'\"
  26. else
  27. echo shar: Extracting \"'MANIFEST'\" \(1491 characters\)
  28. sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
  29. X   File Name        Archive #    Description
  30. X-----------------------------------------------------------
  31. X MANIFEST                   1    
  32. X Makefile                   2    
  33. X README                     1    
  34. X bsd_src                    1    
  35. X bsd_src/Makefile           1    
  36. X bsd_src/cmp.c              1    
  37. X bsd_src/glob.c             2    
  38. X bsd_src/ls.c               3    
  39. X bsd_src/ls.h               1    
  40. X bsd_src/print.c            2    
  41. X bsd_src/random.c           3    
  42. X bsd_src/tweak.h            1    
  43. X bsd_src/util.c             1    
  44. X client_def.h               1    
  45. X client_lib.c               1    
  46. X client_util.c              2    
  47. X common_def.h               2    
  48. X fcatcmd.1                  1    
  49. X fcatcmd.c                  1    
  50. X fcdcmd.1                   1    
  51. X fcdcmd.c                   1    
  52. X fgetcmd.1                  1    
  53. X fgetcmd.c                  1    
  54. X flscmd.1                   1    
  55. X flscmd.c                   1    
  56. X fmkdir.1                   1    
  57. X fmkdir.c                   1    
  58. X fprocmd.1                  1    
  59. X fprocmd.c                  1    
  60. X fput.1                     1    
  61. X fput.c                     1    
  62. X frmcmd.1                   1    
  63. X frmcmd.c                   1    
  64. X frmdircmd.1                1    
  65. X frmdircmd.c                1    
  66. X fspd.1                     1    
  67. X fver.1                     1    
  68. X fver.c                     1    
  69. X server_def.h               1    
  70. X server_file.c              3    
  71. X server_host.c              2    
  72. X server_lib.c               2    
  73. X server_main.c              2    
  74. X setup                      1    
  75. X udp_io.c                   2    
  76. END_OF_FILE
  77. if test 1491 -ne `wc -c <'MANIFEST'`; then
  78.     echo shar: \"'MANIFEST'\" unpacked with wrong size!
  79. fi
  80. # end of 'MANIFEST'
  81. fi
  82. if test -f 'README' -a "${1}" != "-c" ; then 
  83.   echo shar: Will not clobber existing file \"'README'\"
  84. else
  85. echo shar: Extracting \"'README'\" \(13080 characters\)
  86. sed "s/^X//" >'README' <<'END_OF_FILE'
  87. X                        Interested party please email
  88. X                        wen-king@vlsi.cs.caltech.edu
  89. X    What is the purpose of FSP:
  90. X
  91. X    FSP is a set of programs that implements a public-access archive
  92. X    similar to an anonymous-FTP archive.  It is not meant to be a
  93. X    replacement for ftp; it is only meant to do what anonymous-ftp
  94. X    does, but in a manner more acceptible to the provider of the
  95. X    service and more friendly to the clients. 
  96. X
  97. X    Providing anonymous-FTP service can be costly --- each active
  98. X    session consumes one process slot in the OS and one stream socket
  99. X    entry in the network sub-system.  The servers can also run
  100. X    concurrently, adding to the system load.  A popular archive site
  101. X    can easily be overwhelmed as a result.  Some were forced to
  102. X    shutdown or and some impose inconvienent access restrictions. 
  103. X
  104. X    Unlike FTP, FSP is connection-less and virtually state-less.  One
  105. X    server handles requests from all clients machines.  Each active
  106. X    client machine takes up 16-bytes in a dynamically extensible
  107. X    table.  Since only one server runs at any time, the load added
  108. X    to the server machine is less than one.
  109. X
  110. X    In exchange for allowing site operators to keep their sites open
  111. X    and do away with cumbersome access restrictions, this is what the
  112. X    clients accept with FSP: 
  113. X
  114. X     1) Lower transfer rate.  The maximum rate is 1 kbyte per UDP
  115. X        message round-trip time between the client and the server.
  116. X    
  117. X     2) Only one active transfer per client machine.  This is done
  118. X        to minimize the amount of data the server has to keep.
  119. X
  120. X    In addition to the potential for more abundant sites and more
  121. X    accessible sites, this is what the clients gain with FSP:
  122. X
  123. X     1) Robustness.  Since FSP is connectionless, flucturations in
  124. X        the network will not abort a FSP transaction.  Furthermore,
  125. X        the 16-bytes of data for each client can be regenerated at
  126. X        any point during any transaction.  Thus, if the server goes
  127. X        down at any point during a transaction, the transaction will
  128. X        resume when the server is restarted.  (like NFS) 
  129. X
  130. X     2) Friendlier user interface.  FSP does not have its own command
  131. X        interpretor like FTP.  Since it is connectionless, there is
  132. X        no reason to carry much information from one command to the
  133. X        next, and the commands can all be made into individual unix
  134. X        programs.  For instance, there is one program you run to list
  135. X        the directory and another you run to download a file. 
  136. X
  137. X     3) Client protection.  FSP oversees a directory structure similar
  138. X        to that of an anonymous-FTP.  However, a directory created
  139. X        via FSP transaction is owned by the client machine that issued
  140. X        the creation request.  The client can create and delete files
  141. X        and subdirectories in that directory.  In addition, the client
  142. X        can enable any of the two attributes for that directory: 
  143. X
  144. X        A) Give all other clients the permission to create files
  145. X           and subdirectries.
  146. X
  147. X        B) Give all other clients the permission to delete files
  148. X           and subdirectories.
  149. X
  150. X        Note: A subdirectory can be deleted only if it is empty,
  151. X          the client owns the subdirectory, and the client has
  152. X          delete permission for the parent directory containing
  153. X          the subdirectory. 
  154. X
  155. X     4) Server protection.  FSP server does not spawn sub-programs.
  156. X        It will accept only paths that are downward relative to its
  157. X        designated working directory.  On systems with symbolic links,
  158. X        the server will follow symbolic links, but it does not follow
  159. X        uplinks ("..").  Clients cannot create symbolic links and
  160. X        care should be taken so that other users on the server machine
  161. X        cannot create symbolic links in the server's work space. 
  162. X
  163. X        It is also fairly difficult to formuate an attack to force a
  164. X        shutdown of a FSP site by actions of a rogue site.  About the
  165. X        only way to distrupt a FSP service is to flood the FSP site
  166. X        with network packets.  FSP server prevents itself from
  167. X        'counter-flooding' by filtering for legitimate requests using
  168. X        the following method:
  169. X
  170. X        A) Each request message contains a key.  For each client,
  171. X           server database contains the keys to be used for the
  172. X           next client request and for the previous client request.
  173. X
  174. X        B) If the next request does not contain a key that matches
  175. X           either of the two keys, it is accepted only if at least
  176. X           one minute has elapsed since the last time a request
  177. X           is accepted.  If the key does match the old key
  178. X           (retransmit) it is accepted if the elapse time is
  179. X           greater than 3 seconds.
  180. X
  181. X        C) Every request message accepted is acknowledged with
  182. X           one reply message.  The reply message contains a new
  183. X           key to used for the next request.  The new key is
  184. X           computed by the server with a pseudo-random number
  185. X           generator. 
  186. X
  187. X        Flooding is a ballant violation of network etiquette because
  188. X        a site can be subjected to flooding attack whether it has FSP
  189. X        running or not, and flooding congests every link and gateway
  190. X        between the rogue client and the server.  As a further measure
  191. X        of protection, the server loads a table of rogue clients on
  192. X        startup.  The server will not respond to requests from any of
  193. X        those clients.
  194. X
  195. X    The software set:
  196. X
  197. X    common_def.h    This C header file contains definitions common to
  198. X            both the server code and the client code.
  199. X
  200. X    client_def.h    This C header file contains definitions for the
  201. X            client code.
  202. X
  203. X    server_def.h    This C header file contains definitions for the
  204. X            server code.
  205. X
  206. X    udp_io.c    This file contains the lowest level routines that
  207. X            deal with the unix inet sockets.  This file is
  208. X            used by both the server code and the client code.
  209. X
  210. X    server_main.c    Main routine and dispatch loop for the server.
  211. X    server_host.c    Routines for maintaining client database.
  212. X    server_file.c    Routines for file i/o.
  213. X    server_lib.c    Routines for inet socket i/o.
  214. X
  215. X    client_lib.c    Core routines of the client library.
  216. X    client_util.c    Supplementry routines of the client library.
  217. X
  218. X    bsd_src/    Directory containing additional sources derived
  219. X            from those in public archive on uunet.uu.net.  It
  220. X            contains a BSD random/srandom routine, a modified
  221. X            BSD globbing routine, a modified "ls" source.
  222. X
  223. X    fcdcmd.c    These compiles into individual client utilities.
  224. X    fgetcmd.c    Those with a "cmd" in their name will do their
  225. X    flscmd.c    own globbing on their argv base on directory
  226. X    fprocmd.c    information obtained from the server.
  227. X    frmcmd.c
  228. X    frmdircmd.c
  229. X    fcatcmd.c
  230. X    fmkdir.c
  231. X    fput.c
  232. X    fver.c
  233. X
  234. X    Compilation:
  235. X
  236. X    FSP has been compiled and tested on a SS-2 running SunOs 4.1.1,
  237. X    a HP-9000 running HP UNIX, a VAX-780 running 4.3-tahoe, and a 386
  238. X    box running system-V UNIX with old Excelan ethernet interface. 
  239. X
  240. X    To compile the software, you must first successfully complete a
  241. X    "make" in the bsd_src directory.  You may have to change a few
  242. X    files.  In particular, you may have to edit "Makefile" and "tweak.h"
  243. X    in bsd_src directory. 
  244. X
  245. X    When that is done, you can edit the Makefile on the top directory
  246. X    and run "make" in the top directory.  You may have to read through
  247. X    the rest of this document first before making changes to the Makefile.
  248. X
  249. X    Server Administration:
  250. X
  251. X    The only things you need for setting up a FSP server is a work
  252. X    directory for the service and and the FSP server itself (fspd).
  253. X    fspd can run independently or it can be run under inetd.  When
  254. X    running independently, fspd waits for messages through a UDP
  255. X    socket whoes port number is defined in the Makefile.  When running
  256. X    under inetd, fspd is involked as in.fspd.  inetd will spawn fspd
  257. X    when a message arrives for the FSP socket.  The fspd process will
  258. X    take over and stick around to wait on additional messages.  After
  259. X    it has become idle for 2 minutes, fspd will exit and return control
  260. X    to inetd. 
  261. X
  262. X    Sample setup for inetd operation:
  263. X
  264. X        In /etc/services file:
  265. X
  266. X        fsp             21/udp          fspd
  267. X
  268. X        In /etc/inetd.conf file:
  269. X
  270. X        fsp dgram   udp wait ftp /usr/etc/fspd in.fspd
  271. X
  272. X        In this sample, the same port number for ftp is used for the
  273. X        fsp socket.  There will not be a conflict because ftp uses
  274. X        stream protocol, and fsp uses UDP protocol.  The fspd program
  275. X        in this example is ran under user 'ftp'. 
  276. X
  277. X    In addition, fspd will accept these flags:
  278. X
  279. X        -h absolute_path    Set fsp work directory.  Overrides the
  280. X                compiled-in default.
  281. X
  282. X        -p udp_port_number  Set UDP port number.  Overrides the
  283. X                compiled-in default.
  284. X
  285. X        -u uid_number       Assume this uid after startup.  If present,
  286. X                fspd will attempt a setuid() to this uid
  287. X                number.  It will exit if setuid() fails.
  288. X
  289. X        -d                  Turn on debug mode.  The stdio files will
  290. X                remain open in debugging mode.
  291. X
  292. X    When fspd starts, it chdir to its work directory where it looks
  293. X    for (and reads in if found) a list of internet numbers in the
  294. X    standard 4-part form: ddd.ddd.ddd.ddd in the file ".ROGUE_HOSTS".
  295. X    This file is prepared by the FSP maintainer, and is used to
  296. X    indicate that fspd should not respond to any requests from these
  297. X    machines.   After that, it begins to service any requests it gets
  298. X    on the UDP socket.
  299. X
  300. X    If a file .OWN.XXXXXXXX, where XXXXXXXX is an 8-digit hex number,
  301. X    exists in a directory in fspd's work space, the directory is owned
  302. X    by the machine whoes inet number is XXXXXXXX, where the number
  303. X    is printed as a hexadecimal number.  If no such file exists, the
  304. X    directory has no owner.
  305. X
  306. X    If the file .FSP_NO_DEL exists in a directory, only the owner is
  307. X    allowed to remove items from that directory.
  308. X
  309. X    If the file .FSP_NO_ADD exists in a directory, only the owner is
  310. X    allowed to add items into that directory.
  311. X
  312. X    Thus, you typically want to protect the top directory by creating
  313. X    the .FSP_NO_DEL and .FSP_NO_ADD files, and leaving out the
  314. X    .OWN.XXXXXXXX file in the top directory. 
  315. X
  316. X    Clients does not get to read the directory information directory.
  317. X    fspd maintains a directory listing in the file .FSP_CONTENT in
  318. X    each directory.  When a client requests information for a directory,
  319. X    the .FSP_CONTENT file is created if it doesn't exist, and it is
  320. X    rebuilt if it is out of date.  The information is accessed by
  321. X    having the client read the directory listing file.  Care is taken
  322. X    so that the client will not get corrupted entries when the directory
  323. X    is changed while the listing is being read.
  324. X
  325. X    Files being uploaded are first written to a temporary file in the
  326. X    work directory: .TMP.XXXXXXXX where XXXXXXXX is the inet number
  327. X    of the client.  When upload is compelete, the file is moved into
  328. X    the intended location. 
  329. X
  330. X    An 'alarm' interrupt will cause fspd to dump its current client
  331. X    database into the file .HTAB_DUMP in the work directory.  This
  332. X    can be useful for debugging and for catching rogue clients.
  333. X
  334. X    Client utilities:
  335. X
  336. X    All inter-command states are kept in these four shell environment
  337. X    variables.
  338. X
  339. X        FSP_PORT        Port number of the fspd you wish to contact.
  340. X        FSP_HOST        Host name or number of the fspd.
  341. X        FSP_LOCALPORT    Port number to use for talking to fspd.
  342. X        FSP_DIR        Your current working directory in the archive.
  343. X
  344. X    In addition, FSP_TRACE can be set if you want status reports be
  345. X    printed while files are being transferred.
  346. X
  347. X    A typical setup looks like this:
  348. X
  349. X        setenv FSP_PORT     21
  350. X        setenv FSP_HOST     131.215.131.97
  351. X        setenv FSP_LOCALPORT 4334
  352. X        setenv FSP_DIR     /
  353. X        setenv FSP_TRACE
  354. X
  355. X    (All examples will be in csh.  However, it is assumed that similar
  356. X     things can be done with other shells)
  357. X
  358. X    The FSP_LOCALPORT should be the same for all users on the same
  359. X    machine and trying to access to the same server.  It can be used
  360. X    as a way to achieve mutual exclusion to ensure that only one
  361. X    transaction takes place at any time.
  362. X
  363. X    For commands that do globbing using remote directory info, normal
  364. X    shell globbing needs to be turned off.  In csh, it can be done
  365. X    with a set of aliases: 
  366. X
  367. X        alias fcd setenv FSP_DIR \`\(set noglob\; exec fcdcmd \!\*\)\`
  368. X        alias fls    \(set noglob\; exec flscmd    \!\*\)
  369. X        alias fget   \(set noglob\; exec fgetcmd   \!\*\)
  370. X        alias fcat   \(set noglob\; exec fcatcmd   \!\*\)
  371. X        alias frm    \(set noglob\; exec frmcmd    \!\*\)
  372. X        alias frmdir \(set noglob\; exec frmdircmd \!\*\)
  373. X        alias fpro   \(set noglob\; exec fprocmd   \!\*\)
  374. X    
  375. X    In addtion, this alias is useful:
  376. X
  377. X        alias fpwd echo \$FSP_DIR on \$FSP_HOST port \$FSP_PORT
  378. X
  379. X    Commands:
  380. X
  381. X        fver    display server's version number.
  382. X        fcd        change current remote directory, like cd.
  383. X        fls        list directory.  works like ls.
  384. X        fget    get the named files.
  385. X        fput    put the named files.
  386. X        fcat    get the named files and send them to stdout.
  387. X        fmkdir    make named directories.
  388. X        frm        delete named files.
  389. X        frmdir    delete named directories.
  390. X
  391. X        fpro    no arg: display directory protection modes.
  392. X                +c: give others permission to create new items.
  393. X                -c: deny others permission to create new items.
  394. X                +d: give others permission to delete old items.
  395. X                -d: deny others permission to delete old items.
  396. X
  397. X    ***********************************************************************
  398. X
  399. X    This is a free software.  Be creative; make your own macros and tools
  400. X    and let me know of any bugs and suggestions.
  401. END_OF_FILE
  402. if test 13080 -ne `wc -c <'README'`; then
  403.     echo shar: \"'README'\" unpacked with wrong size!
  404. fi
  405. # end of 'README'
  406. fi
  407. if test ! -d 'bsd_src' ; then
  408.     echo shar: Creating directory \"'bsd_src'\"
  409.     mkdir 'bsd_src'
  410. fi
  411. if test -f 'bsd_src/Makefile' -a "${1}" != "-c" ; then 
  412.   echo shar: Will not clobber existing file \"'bsd_src/Makefile'\"
  413. else
  414. echo shar: Extracting \"'bsd_src/Makefile'\" \(516 characters\)
  415. sed "s/^X//" >'bsd_src/Makefile' <<'END_OF_FILE'
  416. X# This subdirectory contains modified version of files obtained from the
  417. X# uunet.uu.net archive.  You need to do 'make' in this directory first.
  418. X# You may have to edit tweak.h to get things to them to properly on your
  419. X# system.
  420. X
  421. CFLAGS=-g
  422. X
  423. all: cmp.o glob.o ls.o print.o util.o random.o
  424. X
  425. cmp.o: cmp.c ls.h tweak.h
  426. glob.o: glob.c ../client_def.h ../common_def.h tweak.h
  427. ls.o: ls.c ../client_def.h ../common_def.h ls.h tweak.h
  428. print.o: print.c ls.h tweak.h
  429. util.o: util.c tweak.h
  430. random.o: random.c
  431. X
  432. clean:
  433. X    rm -f *.o
  434. END_OF_FILE
  435. if test 516 -ne `wc -c <'bsd_src/Makefile'`; then
  436.     echo shar: \"'bsd_src/Makefile'\" unpacked with wrong size!
  437. fi
  438. # end of 'bsd_src/Makefile'
  439. fi
  440. if test -f 'bsd_src/cmp.c' -a "${1}" != "-c" ; then 
  441.   echo shar: Will not clobber existing file \"'bsd_src/cmp.c'\"
  442. else
  443. echo shar: Extracting \"'bsd_src/cmp.c'\" \(1886 characters\)
  444. sed "s/^X//" >'bsd_src/cmp.c' <<'END_OF_FILE'
  445. X/*
  446. X * Copyright (c) 1989 The Regents of the University of California.
  447. X * All rights reserved.
  448. X *
  449. X * This code is derived from software contributed to Berkeley by
  450. X * Michael Fischbein.
  451. X *
  452. X * Redistribution and use in source and binary forms are permitted
  453. X * provided that: (1) source distributions retain this entire copyright
  454. X * notice and comment, and (2) distributions including binaries display
  455. X * the following acknowledgement:  ``This product includes software
  456. X * developed by the University of California, Berkeley and its contributors''
  457. X * in the documentation or other materials provided with the distribution
  458. X * and in all advertising materials mentioning features or use of this
  459. X * software. Neither the name of the University nor the names of its
  460. X * contributors may be used to endorse or promote products derived
  461. X * from this software without specific prior written permission.
  462. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  463. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  464. X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  465. X */
  466. X
  467. X#ifndef lint
  468. static char sccsid[] = "@(#)cmp.c    5.2 (Berkeley) 4/8/90";
  469. X#endif /* not lint */
  470. X
  471. X#include <sys/types.h>
  472. X#include <sys/stat.h>
  473. X#include "ls.h"
  474. X#include "tweak.h"
  475. X
  476. namecmp(a, b)
  477. X    LS *a, *b;
  478. X{
  479. X    return(strcmp(a->name, b->name));
  480. X}
  481. X
  482. revnamecmp(a, b)
  483. X    LS *a, *b;
  484. X{
  485. X    return(strcmp(b->name, a->name));
  486. X}
  487. X
  488. modcmp(a, b)
  489. X    LS *a, *b;
  490. X{
  491. X    return(a->lstat.st_mtime < b->lstat.st_mtime);
  492. X}
  493. X
  494. revmodcmp(a, b)
  495. X    LS *a, *b;
  496. X{
  497. X    return(b->lstat.st_mtime < a->lstat.st_mtime);
  498. X}
  499. X
  500. acccmp(a, b)
  501. X    LS *a, *b;
  502. X{
  503. X    return(a->lstat.st_atime < b->lstat.st_atime);
  504. X}
  505. X
  506. revacccmp(a, b)
  507. X    LS *a, *b;
  508. X{
  509. X    return(b->lstat.st_atime < a->lstat.st_atime);
  510. X}
  511. X
  512. statcmp(a, b)
  513. X    LS *a, *b;
  514. X{
  515. X    return(a->lstat.st_ctime < b->lstat.st_ctime);
  516. X}
  517. X
  518. revstatcmp(a, b)
  519. X    LS *a, *b;
  520. X{
  521. X    return(b->lstat.st_ctime < a->lstat.st_ctime);
  522. X}
  523. END_OF_FILE
  524. if test 1886 -ne `wc -c <'bsd_src/cmp.c'`; then
  525.     echo shar: \"'bsd_src/cmp.c'\" unpacked with wrong size!
  526. fi
  527. # end of 'bsd_src/cmp.c'
  528. fi
  529. if test -f 'bsd_src/ls.h' -a "${1}" != "-c" ; then 
  530.   echo shar: Will not clobber existing file \"'bsd_src/ls.h'\"
  531. else
  532. echo shar: Extracting \"'bsd_src/ls.h'\" \(2175 characters\)
  533. sed "s/^X//" >'bsd_src/ls.h' <<'END_OF_FILE'
  534. X/*
  535. X * Copyright (c) 1989 The Regents of the University of California.
  536. X * All rights reserved.
  537. X *
  538. X * This code is derived from software contributed to Berkeley by
  539. X * Michael Fischbein.
  540. X *
  541. X * Redistribution and use in source and binary forms are permitted
  542. X * provided that: (1) source distributions retain this entire copyright
  543. X * notice and comment, and (2) distributions including binaries display
  544. X * the following acknowledgement:  ``This product includes software
  545. X * developed by the University of California, Berkeley and its contributors''
  546. X * in the documentation or other materials provided with the distribution
  547. X * and in all advertising materials mentioning features or use of this
  548. X * software. Neither the name of the University nor the names of its
  549. X * contributors may be used to endorse or promote products derived
  550. X * from this software without specific prior written permission.
  551. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  552. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  553. X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  554. X *
  555. X *    @(#)ls.h    5.10 (Berkeley) 4/8/90
  556. X */
  557. X
  558. typedef struct _lsstruct {
  559. X    char *name;            /* file name */
  560. X    int len;            /* file name length */
  561. X    struct stat lstat;        /* lstat(2) for file */
  562. X} LS;
  563. X
  564. X/*
  565. X * overload -- we probably have to save blocks and/or maxlen with the lstat
  566. X * array, so tabdir() stuffs it into unused fields in the first stat structure.
  567. X * If there's ever a type larger than u_long, fix this.  Any calls to qsort
  568. X * must save and restore the values.
  569. X */
  570. X#define    st_btotal    st_dev
  571. X#define    st_maxlen    st_rdev
  572. X
  573. extern int errno;
  574. X
  575. extern int f_accesstime;    /* use time of last access */
  576. extern int f_group;        /* show group ownership of a file */
  577. extern int f_inode;        /* print inode */
  578. extern int f_kblocks;        /* print size in kilobytes */
  579. extern int f_longform;        /* long listing format */
  580. extern int f_singlecol;        /* use single column output */
  581. extern int f_size;        /* list size in short listing */
  582. extern int f_statustime;    /* use time of last mode change */
  583. extern int f_total;        /* if precede with "total" line */
  584. extern int f_type;        /* add type character for non-regular files */
  585. END_OF_FILE
  586. if test 2175 -ne `wc -c <'bsd_src/ls.h'`; then
  587.     echo shar: \"'bsd_src/ls.h'\" unpacked with wrong size!
  588. fi
  589. # end of 'bsd_src/ls.h'
  590. fi
  591. if test -f 'bsd_src/tweak.h' -a "${1}" != "-c" ; then 
  592.   echo shar: Will not clobber existing file \"'bsd_src/tweak.h'\"
  593. else
  594. echo shar: Extracting \"'bsd_src/tweak.h'\" \(681 characters\)
  595. sed "s/^X//" >'bsd_src/tweak.h' <<'END_OF_FILE'
  596. X    /*********************************************************************\
  597. X    *  Copyright (c) 1991 by Wen-King Su (wen-king@vlsi.cs.caltech.edu)   *
  598. X    *                                                                     *
  599. X    *  You may copy or modify this file in any manner you wish, provided  *
  600. X    *  that this notice is always included, and that you hold the author  *
  601. X    *  harmless for any loss or damage resulting from the installation or *
  602. X    *  use of this software.                                              *
  603. X    \*********************************************************************/
  604. X
  605. X/* #define d_ino d_fileno        /* */
  606. X/* #define mode_t unsigned short    /* */
  607. END_OF_FILE
  608. if test 681 -ne `wc -c <'bsd_src/tweak.h'`; then
  609.     echo shar: \"'bsd_src/tweak.h'\" unpacked with wrong size!
  610. fi
  611. # end of 'bsd_src/tweak.h'
  612. fi
  613. if test -f 'bsd_src/util.c' -a "${1}" != "-c" ; then 
  614.   echo shar: Will not clobber existing file \"'bsd_src/util.c'\"
  615. else
  616. echo shar: Extracting \"'bsd_src/util.c'\" \(1739 characters\)
  617. sed "s/^X//" >'bsd_src/util.c' <<'END_OF_FILE'
  618. X/*
  619. X * Copyright (c) 1989 The Regents of the University of California.
  620. X * All rights reserved.
  621. X *
  622. X * This code is derived from software contributed to Berkeley by
  623. X * Michael Fischbein.
  624. X *
  625. X * Redistribution and use in source and binary forms are permitted
  626. X * provided that: (1) source distributions retain this entire copyright
  627. X * notice and comment, and (2) distributions including binaries display
  628. X * the following acknowledgement:  ``This product includes software
  629. X * developed by the University of California, Berkeley and its contributors''
  630. X * in the documentation or other materials provided with the distribution
  631. X * and in all advertising materials mentioning features or use of this
  632. X * software. Neither the name of the University nor the names of its
  633. X * contributors may be used to endorse or promote products derived
  634. X * from this software without specific prior written permission.
  635. X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  636. X * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  637. X * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  638. X */
  639. X
  640. X#ifndef lint
  641. static char sccsid[] = "@(#)util.c    5.7 (Berkeley) 4/8/90";
  642. X#endif /* not lint */
  643. X
  644. X#include <sys/types.h>
  645. X#include <stdio.h>
  646. X#include <ctype.h>
  647. X#include "tweak.h"
  648. X
  649. prcopy(src, dest, len)
  650. X    register char *src, *dest;
  651. X    register int len;
  652. X{
  653. X    register int ch;
  654. X
  655. X    while(len--) {
  656. X        ch = *src++;
  657. X        *dest++ = isprint(ch) ? ch : '?';
  658. X    }
  659. X}
  660. X
  661. char
  662. X*emalloc(size)
  663. X    unsigned int size;
  664. X{
  665. X    char *retval, *malloc();
  666. X
  667. X    if (!(retval = malloc(size)))
  668. X        nomem();
  669. X    return(retval);
  670. X}
  671. X
  672. nomem()
  673. X{
  674. X    (void)fprintf(stderr, "ls: out of memory.\n");
  675. X    ls_bad(1);
  676. X}
  677. X
  678. usage()
  679. X{
  680. X    (void)fprintf(stderr, "usage: ls [-1ACFLRacdfgiklqrstu] [file ...]\n");
  681. X    ls_bad(1);
  682. X}
  683. END_OF_FILE
  684. if test 1739 -ne `wc -c <'bsd_src/util.c'`; then
  685.     echo shar: \"'bsd_src/util.c'\" unpacked with wrong size!
  686. fi
  687. # end of 'bsd_src/util.c'
  688. fi
  689. if test -f 'client_def.h' -a "${1}" != "-c" ; then 
  690.   echo shar: Will not clobber existing file \"'client_def.h'\"
  691. else
  692. echo shar: Extracting \"'client_def.h'\" \(1460 characters\)
  693. sed "s/^X//" >'client_def.h' <<'END_OF_FILE'
  694. X    /*********************************************************************\
  695. X    *  Copyright (c) 1991 by Wen-King Su (wen-king@vlsi.cs.caltech.edu)   *
  696. X    *                                                                     *
  697. X    *  You may copy or modify this file in any manner you wish, provided  *
  698. X    *  that this notice is always included, and that you hold the author  *
  699. X    *  harmless for any loss or damage resulting from the installation or *
  700. X    *  use of this software.                                              *
  701. X    \*********************************************************************/
  702. X
  703. X#include "common_def.h"
  704. X
  705. X/****************************************************************************
  706. X* These structures are used to implement a opendir/readdir mechanism similar
  707. X* to that of the normal opendir/reader mechanism in unix.
  708. X****************************************************************************/
  709. X
  710. typedef struct DDLIST {    struct DDLIST *next;
  711. X            char          *path;
  712. X            RDIRENT  **dep_root;
  713. X            int         ref_cnt; } DDLIST;
  714. X
  715. typedef struct RDIR { DDLIST   *ddp;
  716. X              RDIRENT **dep; } RDIR;
  717. X
  718. typedef struct rdirent { unsigned long  d_fileno;
  719. X             unsigned short d_reclen;
  720. X             unsigned short d_namlen;
  721. X             char          *d_name; } rdirent;
  722. X
  723. extern UBUF     *client_interact();
  724. extern RDIRENT **get_dir_blk();
  725. extern rdirent  *util_readdir();
  726. extern RDIR     *util_opendir();
  727. X
  728. extern int client_trace;
  729. extern int client_intr_state;
  730. END_OF_FILE
  731. if test 1460 -ne `wc -c <'client_def.h'`; then
  732.     echo shar: \"'client_def.h'\" unpacked with wrong size!
  733. fi
  734. # end of 'client_def.h'
  735. fi
  736. if test -f 'client_lib.c' -a "${1}" != "-c" ; then 
  737.   echo shar: Will not clobber existing file \"'client_lib.c'\"
  738. else
  739. echo shar: Extracting \"'client_lib.c'\" \(2942 characters\)
  740. sed "s/^X//" >'client_lib.c' <<'END_OF_FILE'
  741. X    /*********************************************************************\
  742. X    *  Copyright (c) 1991 by Wen-King Su (wen-king@vlsi.cs.caltech.edu)   *
  743. X    *                                                                     *
  744. X    *  You may copy or modify this file in any manner you wish, provided  *
  745. X    *  that this notice is always included, and that you hold the author  *
  746. X    *  harmless for any loss or damage resulting from the installation or *
  747. X    *  use of this software.                                              *
  748. X    \*********************************************************************/
  749. X
  750. X#include "client_def.h"
  751. X
  752. extern int errno;
  753. X
  754. static int myfd;
  755. static struct sockaddr_in server_addr;
  756. static unsigned short myseq = 0;
  757. static unsigned short key;
  758. X
  759. int client_trace      = 0;
  760. int client_intr_state = 0;
  761. X
  762. UBUF *client_interact(cmd,pos,l1,p1,l2,p2)
  763. X    unsigned cmd, l1, l2;
  764. X    unsigned long pos;
  765. X    unsigned char *p1, *p2;
  766. X{
  767. X    struct sockaddr_in from;
  768. X    UBUF sbuf;
  769. X    static UBUF rbuf;
  770. X    unsigned char *s, *t, *d;
  771. X    unsigned u, n, sum, mask, mlen;
  772. X    int retval, bytes, retry;
  773. X
  774. X    sbuf.cmd = cmd;
  775. X    sbuf.len = htons(l1);
  776. X    sbuf.pos = htonl(pos);
  777. X
  778. X    client_intr_state = 1;
  779. X
  780. X    for(u = l1, d = (unsigned char *) sbuf.buf; u--; *d++ = *p1++);
  781. X    for(u = l2                      ; u--; *d++ = *p2++);
  782. X    mlen = d - (unsigned char *) &sbuf;
  783. X
  784. X    for(retry = 0; ; retry++)
  785. X    {
  786. X    sbuf.key = key;
  787. X    sbuf.seq = myseq;
  788. X    sbuf.sum = 0;
  789. X
  790. X    for(t = (unsigned char *) &sbuf, sum = n = mlen; n--; sum += *t++);
  791. X    sbuf.sum = sum + (sum >> 8);
  792. X    if(client_trace && retry) write(2,"R",1);
  793. X
  794. X    if(sendto(myfd,&sbuf,mlen,0,&server_addr,sizeof(server_addr)) == -1)
  795. X                        { perror("sendto"); exit(1); }
  796. X    mask = 1 << myfd;
  797. X
  798. X    while(1)
  799. X    {
  800. X        retval = _x_select(&mask, 3000L);
  801. X
  802. X        if((retval == -1) && (errno = EINTR)) continue;
  803. X
  804. X        if(retval == 1)    /* an incoming message is waiting */
  805. X        {
  806. X        bytes = sizeof(from);
  807. X        if((bytes = recvfrom(myfd,(char*)&rbuf,sizeof(rbuf),0,
  808. X                    &from,&bytes)) < UBUF_HSIZE) continue;
  809. X
  810. X        s = (unsigned char *) &rbuf;
  811. X        d = s + bytes;
  812. X        u = rbuf.sum; rbuf.sum = 0;
  813. X        for(t = s, sum = 0; t < d; sum += *t++);
  814. X        sum = (sum + (sum >> 8)) & 0xff;
  815. X        if(sum != u) continue;  /* wrong check sum */
  816. X
  817. X        rbuf.len = htons(rbuf.len);
  818. X        rbuf.pos = htonl(rbuf.pos);
  819. X
  820. X        if(rbuf.seq           != myseq) continue;  /* wrong seq # */
  821. X        if(rbuf.len+UBUF_HSIZE > bytes) continue;  /* truncated.  */
  822. X
  823. X        myseq++; key = rbuf.key;    /* update seq and keys.   */
  824. X
  825. X        if(client_intr_state == 2) { client_done(); exit(1); }
  826. X
  827. X        return(&rbuf);
  828. X
  829. X        } else break;   /* go back to re-transmit buffer again */
  830. X    }
  831. X    }
  832. X}
  833. X
  834. init_client(host,port,myport)
  835. X    char *host;
  836. X    int   port;
  837. X    int myport;
  838. X{
  839. X    if((myfd = _x_udp(&myport)) == -1)
  840. X        { perror("socket open"); exit(1); }
  841. X
  842. X    if(_x_adr(host,port,&server_addr) == -1)
  843. X        { perror("server addr"); exit(1); } 
  844. X}
  845. X
  846. client_done()
  847. X{
  848. X    (void) client_interact(CC_BYE,0L,0,NULLP,0,NULLP);
  849. X}
  850. END_OF_FILE
  851. if test 2942 -ne `wc -c <'client_lib.c'`; then
  852.     echo shar: \"'client_lib.c'\" unpacked with wrong size!
  853. fi
  854. # end of 'client_lib.c'
  855. fi
  856. if test -f 'fcatcmd.1' -a "${1}" != "-c" ; then 
  857.   echo shar: Will not clobber existing file \"'fcatcmd.1'\"
  858. else
  859. echo shar: Extracting \"'fcatcmd.1'\" \(1639 characters\)
  860. sed "s/^X//" >'fcatcmd.1' <<'END_OF_FILE'
  861. X.TH FCAT 1 "8 December 1991"
  862. X.SH NAME
  863. fcatcmd, fcat \- copy files in the FSP database to stdout
  864. X.SH SYNOPSIS
  865. X.B fcatcmd
  866. X.I filename
  867. X\&.\|.\|.
  868. X.LP
  869. X.B fcat
  870. X.I filename
  871. X\&.\|.\|.
  872. X.SH DESCRIPTION
  873. X.LP
  874. XFor each file named in the argument list,
  875. X.B fcatcmd
  876. reads the file and writes the content of the file to its
  877. X.B stdout.
  878. X.LP
  879. X.B fcatcmd
  880. will perform
  881. X.B csh
  882. file name globbing based on file and directory information
  883. obtained from the FSP database.
  884. X.LP
  885. Since user's command shells generally cannot do the proper globbing for
  886. this program, it is recommended that user defines a shell alias or
  887. fucntion to turns off command shell globbing before running this program.
  888. X.B csh
  889. example:
  890. X.LP
  891. X.nf
  892. alias fcat \e(set noglob\e; exec fcatcmd \e!\e*\e)
  893. X.fi
  894. X.SH ENVIRONMENT
  895. X.LP
  896. The following variables associate this program with a FSP database:
  897. X.TP
  898. X.B FSP_HOST
  899. The name or internet number of the machine with the FSP server.
  900. X.TP
  901. X.B FSP_PORT
  902. The port number of the UDP socket used by the FSP server.
  903. X.TP
  904. X.B FSP_LOCALPORT
  905. The port number of the UDP socket used by FSP client utilities.
  906. You may pick any number not currently used for other purposes.
  907. The main reason of defining this number is to ensure mutual
  908. exclusion between client utilities accessing the same FSP database.
  909. X.TP
  910. X.B FSP_DIR
  911. The current working directory of the client in the FSP database.
  912. The root of the database is /.
  913. X.TP
  914. X.B FSP_TRACE
  915. If this variable is set,
  916. X.B fcatcmd
  917. will display the number of kilo-byte blocks transfered as transfer
  918. progresses.
  919. X.SH "SEE ALSO"
  920. X.PD
  921. fcatcmd(1), fcdcmd(1), fgetcmd(1), flscmd(1), fmkdir(1),
  922. fprocmd(1), fput(1), frmcmd(1), frmdircmd(1), fver(1), fspd(1)
  923. END_OF_FILE
  924. if test 1639 -ne `wc -c <'fcatcmd.1'`; then
  925.     echo shar: \"'fcatcmd.1'\" unpacked with wrong size!
  926. fi
  927. # end of 'fcatcmd.1'
  928. fi
  929. if test -f 'fcatcmd.c' -a "${1}" != "-c" ; then 
  930.   echo shar: Will not clobber existing file \"'fcatcmd.c'\"
  931. else
  932. echo shar: Extracting \"'fcatcmd.c'\" \(1140 characters\)
  933. sed "s/^X//" >'fcatcmd.c' <<'END_OF_FILE'
  934. X    /*********************************************************************\
  935. X    *  Copyright (c) 1991 by Wen-King Su (wen-king@vlsi.cs.caltech.edu)   *
  936. X    *                                                                     *
  937. X    *  You may copy or modify this file in any manner you wish, provided  *
  938. X    *  that this notice is always included, and that you hold the author  *
  939. X    *  harmless for any loss or damage resulting from the installation or *
  940. X    *  use of this software.                                              *
  941. X    \*********************************************************************/
  942. X
  943. X#include "client_def.h"
  944. X
  945. extern char **glob();
  946. dont_die(){}
  947. X
  948. main(argc,argv,envp)
  949. X    int argc;
  950. X    char **argv,**envp;
  951. X{
  952. X    char **av, *av2[2];
  953. X
  954. X    env_client();
  955. X
  956. X    signal(SIGPIPE,dont_die);
  957. X
  958. X    while(*++argv)
  959. X    {
  960. X    if(!(av = glob(*argv))) { av = av2; av2[0] = *argv; av2[1] = 0; }
  961. X    while(*av) get_file(*av++);
  962. X    }
  963. X
  964. X    client_done();
  965. X
  966. X    exit(0);
  967. X}
  968. X
  969. get_file(path)
  970. X    char *path;
  971. X{
  972. X    char *name, *t2;
  973. X    FILE *fp;
  974. X
  975. X    for(name = t2 = path; *t2; t2++) if(*t2 == '/') name = t2 + 1;
  976. X    util_download(path,stdout);
  977. X}
  978. END_OF_FILE
  979. if test 1140 -ne `wc -c <'fcatcmd.c'`; then
  980.     echo shar: \"'fcatcmd.c'\" unpacked with wrong size!
  981. fi
  982. # end of 'fcatcmd.c'
  983. fi
  984. if test -f 'fcdcmd.1' -a "${1}" != "-c" ; then 
  985.   echo shar: Will not clobber existing file \"'fcdcmd.1'\"
  986. else
  987. echo shar: Extracting \"'fcdcmd.1'\" \(2087 characters\)
  988. sed "s/^X//" >'fcdcmd.1' <<'END_OF_FILE'
  989. X.TH FCD 1 "8 December 1991"
  990. X.SH NAME
  991. fcdcmd, fcd \- change client's current working directory in the FSP database
  992. X.SH SYNOPSIS
  993. X.B fcdcmd
  994. X.I path
  995. X.LP
  996. X.B fcd
  997. X.I path
  998. X.SH DESCRIPTION
  999. X.LP
  1000. If no paths are given, / is used as the current working directory.  If
  1001. X.I path
  1002. begins with a /,
  1003. X.B fcdcmd
  1004. uses it as the current working directory.  Otherwise,
  1005. X.B fcdcmd
  1006. appends
  1007. X.I path
  1008. to the end of the current working directory.  In both cases,
  1009. X.B fcdcmd
  1010. simplifies the new path and writes it to the
  1011. X.I stdout.
  1012. In order for the effect of
  1013. X.B fcdcmd
  1014. to be felt in subsequent FSP transactions, user needs to save the
  1015. X.I stdout
  1016. output in the
  1017. X.I FSP_DIR
  1018. variable.  If the change is successful,
  1019. X.B fcdcmd
  1020. will display the protection setting of the new working directory.
  1021. X.LP
  1022. X.B fcdcmd
  1023. will perform
  1024. X.B csh
  1025. file name globbing based on file and directory information
  1026. obtained from the FSP database.
  1027. X.LP
  1028. Since user's command shells generally cannot do the proper globbing for
  1029. this program, it is recommended that user defines a shell alias or
  1030. fucntion to turns off command shell globbing before running this program.
  1031. X.B csh
  1032. example:
  1033. X.LP
  1034. X.nf
  1035. alias fcd setenv FSP_DIR \e`\e(set noglob\e; exec fcdcmd \e!\e*\e)\e`
  1036. X.fi
  1037. X.SH ENVIRONMENT
  1038. X.LP
  1039. The following variables associate this program with a FSP database:
  1040. X.TP
  1041. X.B FSP_HOST
  1042. The name or internet number of the machine with the FSP server.
  1043. X.TP
  1044. X.B FSP_PORT
  1045. The port number of the UDP socket used by the FSP server.
  1046. X.TP
  1047. X.B FSP_LOCALPORT
  1048. The port number of the UDP socket used by FSP client utilities.
  1049. You may pick any number not currently used for other purposes.
  1050. The main reason of defining this number is to ensure mutual
  1051. exclusion between client utilities accessing the same FSP database.
  1052. X.TP
  1053. X.B FSP_DIR
  1054. The current working directory of the client in the FSP database.
  1055. The root of the database is /.
  1056. X.SH "SEE ALSO"
  1057. X.PD
  1058. fcatcmd(1), fcdcmd(1), fgetcmd(1), flscmd(1), fmkdir(1),
  1059. fprocmd(1), fput(1), frmcmd(1), frmdircmd(1), fver(1), fspd(1)
  1060. X.br
  1061. X.ne 5
  1062. X.SH BUGS
  1063. X.LP
  1064. If more than one
  1065. X.B paths
  1066. are given, only the first one will be used.
  1067. The rest will be silently ignored.
  1068. END_OF_FILE
  1069. if test 2087 -ne `wc -c <'fcdcmd.1'`; then
  1070.     echo shar: \"'fcdcmd.1'\" unpacked with wrong size!
  1071. fi
  1072. # end of 'fcdcmd.1'
  1073. fi
  1074. if test -f 'fcdcmd.c' -a "${1}" != "-c" ; then 
  1075.   echo shar: Will not clobber existing file \"'fcdcmd.c'\"
  1076. else
  1077. echo shar: Extracting \"'fcdcmd.c'\" \(1359 characters\)
  1078. sed "s/^X//" >'fcdcmd.c' <<'END_OF_FILE'
  1079. X    /*********************************************************************\
  1080. X    *  Copyright (c) 1991 by Wen-King Su (wen-king@vlsi.cs.caltech.edu)   *
  1081. X    *                                                                     *
  1082. X    *  You may copy or modify this file in any manner you wish, provided  *
  1083. X    *  that this notice is always included, and that you hold the author  *
  1084. X    *  harmless for any loss or damage resulting from the installation or *
  1085. X    *  use of this software.                                              *
  1086. X    \*********************************************************************/
  1087. X
  1088. X#include "client_def.h"
  1089. X
  1090. extern char **glob();
  1091. extern char *env_dir;
  1092. extern char *util_abs_path();
  1093. X
  1094. main(argc,argv)
  1095. X    int argc;
  1096. X    char **argv;
  1097. X{
  1098. X    char *np;
  1099. X    char **av, *av2[2];
  1100. X
  1101. X    env_client();
  1102. X    if(argc == 1)
  1103. X    {
  1104. X    print_pro("/");
  1105. X    puts("/");
  1106. X    }
  1107. X    else
  1108. X    {
  1109. X        if(!(av = glob(argv[1]))) { av = av2; av2[0] = *argv; av2[1] = 0; }
  1110. X    np = util_abs_path(*av);
  1111. X    if(print_pro(np)) puts(np); else puts(env_dir);
  1112. X    }
  1113. X    client_done();
  1114. X    exit(0);
  1115. X}
  1116. X
  1117. print_pro(p)
  1118. X    char *p;
  1119. X{
  1120. X    UBUF *ub;
  1121. X
  1122. X    ub = client_interact(CC_GET_PRO,0L, strlen(p),p+1, 0,NULLP);
  1123. X
  1124. X    if(ub->cmd == CC_ERR)
  1125. X    {
  1126. X    fprintf(stderr,"ERR: %s\n",ub->buf);
  1127. X    return(0);
  1128. X
  1129. X    } else
  1130. X    {
  1131. X    fprintf(stderr,"directory mode: %s\n",ub->buf);
  1132. X    return(1);
  1133. X    }
  1134. X}
  1135. END_OF_FILE
  1136. if test 1359 -ne `wc -c <'fcdcmd.c'`; then
  1137.     echo shar: \"'fcdcmd.c'\" unpacked with wrong size!
  1138. fi
  1139. # end of 'fcdcmd.c'
  1140. fi
  1141. if test -f 'fgetcmd.1' -a "${1}" != "-c" ; then 
  1142.   echo shar: Will not clobber existing file \"'fgetcmd.1'\"
  1143. else
  1144. echo shar: Extracting \"'fgetcmd.1'\" \(1649 characters\)
  1145. sed "s/^X//" >'fgetcmd.1' <<'END_OF_FILE'
  1146. X.TH FGET 1 "8 December 1991"
  1147. X.SH NAME
  1148. fgetcmd, fget \- download files from the FSP database
  1149. X.SH SYNOPSIS
  1150. X.B fgetcmd
  1151. X.I filename
  1152. X\&.\|.\|.
  1153. X.LP
  1154. X.B fget
  1155. X.I filename
  1156. X\&.\|.\|.
  1157. X.SH DESCRIPTION
  1158. X.LP
  1159. XFor each file named in the argument list,
  1160. X.B fgetcmd
  1161. copies the file to the client's current working directory in the
  1162. client machine.
  1163. X.B fgetcmd
  1164. will perform
  1165. X.B csh
  1166. file name globbing based on file and directory information
  1167. obtained from the FSP database.
  1168. X.LP
  1169. Since user's command shells generally cannot do the proper globbing for
  1170. this program, it is recommended that user defines a shell alias or
  1171. fucntion to turns off command shell globbing before running this program.
  1172. X.B csh
  1173. example:
  1174. X.LP
  1175. X.nf
  1176. alias fget \e(set noglob\e; exec fgetcmd \e!\e*\e)
  1177. X.fi
  1178. X.SH ENVIRONMENT
  1179. X.LP
  1180. The following variables associate this program with a FSP database:
  1181. X.TP
  1182. X.B FSP_HOST
  1183. The name or internet number of the machine with the FSP server.
  1184. X.TP
  1185. X.B FSP_PORT
  1186. The port number of the UDP socket used by the FSP server.
  1187. X.TP
  1188. X.B FSP_LOCALPORT
  1189. The port number of the UDP socket used by FSP client utilities.
  1190. You may pick any number not currently used for other purposes.
  1191. The main reason of defining this number is to ensure mutual
  1192. exclusion between client utilities accessing the same FSP database.
  1193. X.TP
  1194. X.B FSP_DIR
  1195. The current working directory of the client in the FSP database.
  1196. The root of the database is /.
  1197. X.TP
  1198. X.B FSP_TRACE
  1199. If this variable is set,   
  1200. X.B fgetcmd
  1201. will display the number of kilo-byte blocks transfered as transfer 
  1202. progresses. 
  1203. X.SH "SEE ALSO"
  1204. X.PD
  1205. fcatcmd(1), fcdcmd(1), fgetcmd(1), flscmd(1), fmkdir(1),
  1206. fprocmd(1), fput(1), frmcmd(1), frmdircmd(1), fver(1), fspd(1)
  1207. END_OF_FILE
  1208. if test 1649 -ne `wc -c <'fgetcmd.1'`; then
  1209.     echo shar: \"'fgetcmd.1'\" unpacked with wrong size!
  1210. fi
  1211. # end of 'fgetcmd.1'
  1212. fi
  1213. if test -f 'fgetcmd.c' -a "${1}" != "-c" ; then 
  1214.   echo shar: Will not clobber existing file \"'fgetcmd.c'\"
  1215. else
  1216. echo shar: Extracting \"'fgetcmd.c'\" \(1261 characters\)
  1217. sed "s/^X//" >'fgetcmd.c' <<'END_OF_FILE'
  1218. X    /*********************************************************************\
  1219. X    *  Copyright (c) 1991 by Wen-King Su (wen-king@vlsi.cs.caltech.edu)   *
  1220. X    *                                                                     *
  1221. X    *  You may copy or modify this file in any manner you wish, provided  *
  1222. X    *  that this notice is always included, and that you hold the author  *
  1223. X    *  harmless for any loss or damage resulting from the installation or *
  1224. X    *  use of this software.                                              *
  1225. X    \*********************************************************************/
  1226. X
  1227. X#include "client_def.h"
  1228. X
  1229. extern char **glob();
  1230. X
  1231. main(argc,argv,envp)
  1232. X    int argc;
  1233. X    char **argv,**envp;
  1234. X{
  1235. X    char **av, *av2[2];
  1236. X
  1237. X    env_client();
  1238. X
  1239. X    while(*++argv)
  1240. X    {
  1241. X    if(!(av = glob(*argv))) { av = av2; av2[0] = *argv; av2[1] = 0; }
  1242. X    while(*av) get_file(*av++);
  1243. X    }
  1244. X
  1245. X    client_done();
  1246. X
  1247. X    exit(0);
  1248. X}
  1249. X
  1250. get_file(path)
  1251. X    char *path;
  1252. X{
  1253. X    char *name, *t2;
  1254. X    FILE *fp;
  1255. X
  1256. X    for(name = t2 = path; *t2; t2++) if(*t2 == '/') name = t2 + 1;
  1257. X
  1258. X    if(fp = fopen(name,"w"))
  1259. X    {
  1260. X    if(util_download(path,fp) == -1) { fclose(fp); unlink(name); }
  1261. X                    else { fclose(fp);               }
  1262. X
  1263. X    } else fprintf(stderr,"Cannot write %s\n",name);
  1264. X}
  1265. END_OF_FILE
  1266. if test 1261 -ne `wc -c <'fgetcmd.c'`; then
  1267.     echo shar: \"'fgetcmd.c'\" unpacked with wrong size!
  1268. fi
  1269. # end of 'fgetcmd.c'
  1270. fi
  1271. if test -f 'flscmd.1' -a "${1}" != "-c" ; then 
  1272.   echo shar: Will not clobber existing file \"'flscmd.1'\"
  1273. else
  1274. echo shar: Extracting \"'flscmd.1'\" \(1881 characters\)
  1275. sed "s/^X//" >'flscmd.1' <<'END_OF_FILE'
  1276. X.TH FLS 1 "8 December 1991"
  1277. X.SH NAME
  1278. flscmd, fls \- list the contents of a FSP database
  1279. X.SH SYNOPSIS
  1280. X.B flscmd
  1281. X[
  1282. X.B unix ls flags
  1283. X]
  1284. X.I filename
  1285. X\&.\|.\|.
  1286. X.LP
  1287. X.B fls
  1288. X[
  1289. X.B unix ls flags
  1290. X]
  1291. X.I filename
  1292. X\&.\|.\|.
  1293. X.SH DESCRIPTION
  1294. X.LP
  1295. X.B flscmd
  1296. lists the content of the FSP database.  All usual
  1297. flags and usages for the unix
  1298. X.B ls
  1299. command are accepted.
  1300. X.LP
  1301. X.B flscmd
  1302. will perform
  1303. X.B csh
  1304. file name globbing based on file and directory information
  1305. obtained from the FSP database.
  1306. X.LP
  1307. Since user's command shells generally cannot do the proper globbing for
  1308. this program, it is recommended that user defines a shell alias or
  1309. fucntion to turns off command shell globbing before running this program.
  1310. X.B csh
  1311. example:
  1312. X.LP
  1313. X.nf
  1314. alias fls \e(set noglob\e; exec flscmd \e!\e*\e)
  1315. X.fi
  1316. X.SH ENVIRONMENT
  1317. X.LP
  1318. The following variables associate this program with a FSP database:
  1319. X.TP
  1320. X.B FSP_HOST
  1321. The name or internet number of the machine with the FSP server.
  1322. X.TP
  1323. X.B FSP_PORT
  1324. The port number of the UDP socket used by the FSP server.
  1325. X.TP
  1326. X.B FSP_LOCALPORT
  1327. The port number of the UDP socket used by FSP client utilities.
  1328. You may pick any number not currently used for other purposes.
  1329. The main reason of defining this number is to ensure mutual
  1330. exclusion between client utilities accessing the same FSP database.
  1331. X.TP
  1332. X.B FSP_DIR
  1333. The current working directory of the client in the FSP database.
  1334. The root of the database is /.
  1335. X.SH "SEE ALSO"
  1336. X.PD
  1337. fcatcmd(1), fcdcmd(1), fgetcmd(1), flscmd(1), fmkdir(1),
  1338. fprocmd(1), fput(1), frmcmd(1), frmdircmd(1), fver(1), fspd(1)
  1339. X.br
  1340. X.ne 5
  1341. X.SH BUGS
  1342. X.LP
  1343. X.B flscmd
  1344. is based on 4.3
  1345. X.B ls
  1346. code.  It inherits any bugs found in 4.3
  1347. X.B ls.
  1348. In addition, only four pieces of information for each file and directory
  1349. are available through FSP:
  1350. X.B name,
  1351. X.B time,
  1352. X.B size,
  1353. and
  1354. X.B type.
  1355. All other information that
  1356. X.B flscmd
  1357. display are for compatibility purposes only
  1358. and are forged locally.
  1359. END_OF_FILE
  1360. if test 1881 -ne `wc -c <'flscmd.1'`; then
  1361.     echo shar: \"'flscmd.1'\" unpacked with wrong size!
  1362. fi
  1363. # end of 'flscmd.1'
  1364. fi
  1365. if test -f 'flscmd.c' -a "${1}" != "-c" ; then 
  1366.   echo shar: Will not clobber existing file \"'flscmd.c'\"
  1367. else
  1368. echo shar: Extracting \"'flscmd.c'\" \(880 characters\)
  1369. sed "s/^X//" >'flscmd.c' <<'END_OF_FILE'
  1370. X    /*********************************************************************\
  1371. X    *  Copyright (c) 1991 by Wen-King Su (wen-king@vlsi.cs.caltech.edu)   *
  1372. X    *                                                                     *
  1373. X    *  You may copy or modify this file in any manner you wish, provided  *
  1374. X    *  that this notice is always included, and that you hold the author  *
  1375. X    *  harmless for any loss or damage resulting from the installation or *
  1376. X    *  use of this software.                                              *
  1377. X    \*********************************************************************/
  1378. X
  1379. X#include "client_def.h"
  1380. X
  1381. main(argc,argv,envp)
  1382. X    int argc;
  1383. X    char **argv,**envp;
  1384. X{
  1385. X    unsigned long pos;
  1386. X    RDIRENT **dp;
  1387. X
  1388. X    env_client();
  1389. X
  1390. X    fls_main(argc,argv,envp);
  1391. X
  1392. X    client_done();
  1393. X
  1394. X    exit(0);
  1395. X}
  1396. X
  1397. ls_bad(n)
  1398. X    int n;
  1399. X{
  1400. X    client_done();
  1401. X    exit(n);
  1402. X}
  1403. END_OF_FILE
  1404. if test 880 -ne `wc -c <'flscmd.c'`; then
  1405.     echo shar: \"'flscmd.c'\" unpacked with wrong size!
  1406. fi
  1407. # end of 'flscmd.c'
  1408. fi
  1409. if test -f 'fmkdir.1' -a "${1}" != "-c" ; then 
  1410.   echo shar: Will not clobber existing file \"'fmkdir.1'\"
  1411. else
  1412. echo shar: Extracting \"'fmkdir.1'\" \(1293 characters\)
  1413. sed "s/^X//" >'fmkdir.1' <<'END_OF_FILE'
  1414. X.TH FMKDIR 1 "8 December 1991"
  1415. X.SH NAME
  1416. fmkdir \- create directories in the FSP database
  1417. X.SH SYNOPSIS
  1418. X.B fmkdir
  1419. X.I name
  1420. X\&.\|.\|.
  1421. X.SH DESCRIPTION
  1422. X.LP
  1423. XFor each
  1424. X.I name
  1425. appearing in the argument list,
  1426. X.B fmkdir
  1427. creates a directory in the client's current working directory
  1428. in the FSP database.  The new directories are owned by the
  1429. client machine, and permission for other machines to create or
  1430. delete items in these directories are initially turned off.
  1431. The client may alter the permission states with the
  1432. X.B fprocmd
  1433. command.
  1434. X.SH ENVIRONMENT
  1435. X.LP
  1436. The following variables associate this program with a FSP database:
  1437. X.TP
  1438. X.B FSP_HOST
  1439. The name or internet number of the machine with the FSP server.
  1440. X.TP
  1441. X.B FSP_PORT
  1442. The port number of the UDP socket used by the FSP server.
  1443. X.TP
  1444. X.B FSP_LOCALPORT
  1445. The port number of the UDP socket used by FSP client utilities.
  1446. You may pick any number not currently used for other purposes.
  1447. The main reason of defining this number is to ensure mutual
  1448. exclusion between client utilities accessing the same FSP database.
  1449. X.TP
  1450. X.B FSP_DIR
  1451. The current working directory of the client in the FSP database.
  1452. The root of the database is /.
  1453. X.SH "SEE ALSO"
  1454. X.PD
  1455. fcatcmd(1), fcdcmd(1), fgetcmd(1), flscmd(1), fmkdir(1),
  1456. fprocmd(1), fput(1), frmcmd(1), frmdircmd(1), fver(1), fspd(1)
  1457. END_OF_FILE
  1458. if test 1293 -ne `wc -c <'fmkdir.1'`; then
  1459.     echo shar: \"'fmkdir.1'\" unpacked with wrong size!
  1460. fi
  1461. # end of 'fmkdir.1'
  1462. fi
  1463. if test -f 'fmkdir.c' -a "${1}" != "-c" ; then 
  1464.   echo shar: Will not clobber existing file \"'fmkdir.c'\"
  1465. else
  1466. echo shar: Extracting \"'fmkdir.c'\" \(1186 characters\)
  1467. sed "s/^X//" >'fmkdir.c' <<'END_OF_FILE'
  1468. X    /*********************************************************************\
  1469. X    *  Copyright (c) 1991 by Wen-King Su (wen-king@vlsi.cs.caltech.edu)   *
  1470. X    *                                                                     *
  1471. X    *  You may copy or modify this file in any manner you wish, provided  *
  1472. X    *  that this notice is always included, and that you hold the author  *
  1473. X    *  harmless for any loss or damage resulting from the installation or *
  1474. X    *  use of this software.                                              *
  1475. X    \*********************************************************************/
  1476. X
  1477. X#include "client_def.h"
  1478. X
  1479. extern char **glob(), *util_abs_path();
  1480. X
  1481. main(argc,argv,envp)
  1482. X    int argc;
  1483. X    char **argv,**envp;
  1484. X{
  1485. X    char **av, *av2[2];
  1486. X
  1487. X    env_client();
  1488. X    while(*++argv) make_dir(*argv);
  1489. X    client_done();
  1490. X
  1491. X    exit(0);
  1492. X}
  1493. X
  1494. make_dir(p)
  1495. X    char *p;
  1496. X{
  1497. X    char *op;
  1498. X    UBUF *ub;
  1499. X
  1500. X    op = util_abs_path(p);
  1501. X
  1502. X    ub = client_interact(CC_MAKE_DIR,0L, strlen(op),op+1, 0,NULLP);
  1503. X
  1504. X    if(ub->cmd == CC_ERR)
  1505. X    {
  1506. X    fprintf(stderr,"Can't create %s: %s\n",p,ub->buf);
  1507. X    free(op); return(-1);
  1508. X    }
  1509. X
  1510. X    printf("%s\t: %s\n",p,ub->buf);
  1511. X
  1512. X    free(op);
  1513. X    return(0);
  1514. X}
  1515. END_OF_FILE
  1516. if test 1186 -ne `wc -c <'fmkdir.c'`; then
  1517.     echo shar: \"'fmkdir.c'\" unpacked with wrong size!
  1518. fi
  1519. # end of 'fmkdir.c'
  1520. fi
  1521. if test -f 'fprocmd.1' -a "${1}" != "-c" ; then 
  1522.   echo shar: Will not clobber existing file \"'fprocmd.1'\"
  1523. else
  1524. echo shar: Extracting \"'fprocmd.1'\" \(1977 characters\)
  1525. sed "s/^X//" >'fprocmd.1' <<'END_OF_FILE'
  1526. X.TH FPRO 1 "8 December 1991"
  1527. X.SH NAME
  1528. fprocmd, fpro \- get or set permissions for directories in the FSP database
  1529. X.SH SYNOPSIS
  1530. X.B fprocmd
  1531. X[
  1532. X.B +c|-c|+d|-d
  1533. X]
  1534. X.I directory
  1535. X\&.\|.\|.
  1536. X.LP
  1537. X.B fpro
  1538. X[
  1539. X.B +c|-c|+d|-d
  1540. X]
  1541. X.I directory
  1542. X\&.\|.\|.
  1543. X.SH DESCRIPTION
  1544. X.LP
  1545. If no flags are specified, for each file named in the argument list,
  1546. X.B fprocmd
  1547. displays the current permission settings for each directory named.
  1548. If a flag is present (only one may be specified each time),
  1549. X.B fprocmd
  1550. will perform the following operations
  1551. and display the resulting settings for each named directory:
  1552. X.TP
  1553. X.B +c
  1554. Give others permission to create new items.
  1555. X.TP
  1556. X.B -c
  1557. Deny others permission to create new items.
  1558. X.TP
  1559. X.B +d
  1560. Give others permission to delete old items.
  1561. X.TP
  1562. X.B -d
  1563. Deny others permission to delete old items.
  1564. X.LP
  1565. X.B fprocmd
  1566. will perform
  1567. X.B csh
  1568. file name globbing based on file and directory information
  1569. obtained from the FSP database.
  1570. X.LP
  1571. Since user's command shells generally cannot do the proper globbing for
  1572. this program, it is recommended that user defines a shell alias or
  1573. fucntion to turns off command shell globbing before running this program.
  1574. X.B csh
  1575. example:
  1576. X.LP
  1577. X.nf
  1578. alias fpro \e(set noglob\e; exec fprocmd \e!\e*\e)
  1579. X.fi
  1580. X.SH ENVIRONMENT
  1581. X.LP
  1582. The following variables associate this program with a FSP database:
  1583. X.TP
  1584. X.B FSP_HOST
  1585. The name or internet number of the machine with the FSP server.
  1586. X.TP
  1587. X.B FSP_PORT
  1588. The port number of the UDP socket used by the FSP server.
  1589. X.TP
  1590. X.B FSP_LOCALPORT
  1591. The port number of the UDP socket used by FSP client utilities.
  1592. You may pick any number not currently used for other purposes.
  1593. The main reason of defining this number is to ensure mutual
  1594. exclusion between client utilities accessing the same FSP database.
  1595. X.TP
  1596. X.B FSP_DIR
  1597. The current working directory of the client in the FSP database.
  1598. The root of the database is /.
  1599. X.SH "SEE ALSO"
  1600. X.PD
  1601. fcatcmd(1), fcdcmd(1), fgetcmd(1), flscmd(1), fmkdir(1),
  1602. fprocmd(1), fput(1), frmcmd(1), frmdircmd(1), fver(1), fspd(1)
  1603. END_OF_FILE
  1604. if test 1977 -ne `wc -c <'fprocmd.1'`; then
  1605.     echo shar: \"'fprocmd.1'\" unpacked with wrong size!
  1606. fi
  1607. # end of 'fprocmd.1'
  1608. fi
  1609. if test -f 'fprocmd.c' -a "${1}" != "-c" ; then 
  1610.   echo shar: Will not clobber existing file \"'fprocmd.c'\"
  1611. else
  1612. echo shar: Extracting \"'fprocmd.c'\" \(1706 characters\)
  1613. sed "s/^X//" >'fprocmd.c' <<'END_OF_FILE'
  1614. X    /*********************************************************************\
  1615. X    *  Copyright (c) 1991 by Wen-King Su (wen-king@vlsi.cs.caltech.edu)   *
  1616. X    *                                                                     *
  1617. X    *  You may copy or modify this file in any manner you wish, provided  *
  1618. X    *  that this notice is always included, and that you hold the author  *
  1619. X    *  harmless for any loss or damage resulting from the installation or *
  1620. X    *  use of this software.                                              *
  1621. X    \*********************************************************************/
  1622. X
  1623. X#include "client_def.h"
  1624. X
  1625. extern char **glob(), *util_abs_path();
  1626. X
  1627. main(argc,argv,envp)
  1628. X    int argc;
  1629. X    char **argv,**envp;
  1630. X{
  1631. X    char **av, *av2[2], *key;
  1632. X
  1633. X    env_client();
  1634. X
  1635. X    if(argv[1]    && (argv[1][0] == '+' || argv[1][0] == '-')
  1636. X        && (argv[1][1] == 'c' || argv[1][1] == 'd'))
  1637. X    {
  1638. X        key = *++argv;
  1639. X
  1640. X    while(*++argv)
  1641. X    {
  1642. X        if(!(av = glob(*argv))) { av = av2; av2[0] = *argv; av2[1] = 0; }
  1643. X        while(*av) set_pro(*av++,key);
  1644. X    }
  1645. X
  1646. X    } else
  1647. X    {
  1648. X    if(argv[1]) while(*++argv)
  1649. X    {
  1650. X        if(!(av = glob(*argv))) { av = av2; av2[0] = *argv; av2[1] = 0; }
  1651. X        while(*av) print_pro(*av++);
  1652. X
  1653. X    } else print_pro(".");
  1654. X    }
  1655. X
  1656. X    client_done();
  1657. X
  1658. X    exit(0);
  1659. X}
  1660. X
  1661. print_pro(p)
  1662. X    char *p;
  1663. X{
  1664. X    char *op;
  1665. X    UBUF *ub;
  1666. X
  1667. X    op = util_abs_path(p);
  1668. X
  1669. X    ub = client_interact(CC_GET_PRO,0L, strlen(op),op+1, 0,NULLP);
  1670. X
  1671. X    printf("%s\t: %s\n",p,ub->buf);
  1672. X
  1673. X    return(0);
  1674. X}
  1675. X
  1676. set_pro(p,key)
  1677. X    char *p, *key;
  1678. X{
  1679. X    char *op;
  1680. X    UBUF *ub;
  1681. X
  1682. X    op = util_abs_path(p);
  1683. X
  1684. X    ub = client_interact(CC_SET_PRO,0L, strlen(op),op+1, strlen(key)+1,key);
  1685. X
  1686. X    printf("%s\t: %s\n",p,ub->buf);
  1687. X
  1688. X    return(0);
  1689. X}
  1690. END_OF_FILE
  1691. if test 1706 -ne `wc -c <'fprocmd.c'`; then
  1692.     echo shar: \"'fprocmd.c'\" unpacked with wrong size!
  1693. fi
  1694. # end of 'fprocmd.c'
  1695. fi
  1696. if test -f 'fput.1' -a "${1}" != "-c" ; then 
  1697.   echo shar: Will not clobber existing file \"'fput.1'\"
  1698. else
  1699. echo shar: Extracting \"'fput.1'\" \(1197 characters\)
  1700. sed "s/^X//" >'fput.1' <<'END_OF_FILE'
  1701. X.TH FPUT 1 "8 December 1991"
  1702. X.SH NAME
  1703. fput \- upload files to the FSP database
  1704. X.SH SYNOPSIS
  1705. X.B fput
  1706. X.I filename
  1707. X\&.\|.\|.
  1708. X.SH DESCRIPTION
  1709. X.LP
  1710. XFor each file named in the argument list,
  1711. X.B fput
  1712. copies the file from the client's current working directory in the
  1713. client machine to the FSP database.
  1714. X.SH ENVIRONMENT
  1715. X.LP
  1716. The following variables associate this program with a FSP database:
  1717. X.TP
  1718. X.B FSP_HOST
  1719. The name or internet number of the machine with the FSP server.
  1720. X.TP
  1721. X.B FSP_PORT
  1722. The port number of the UDP socket used by the FSP server.
  1723. X.TP
  1724. X.B FSP_LOCALPORT
  1725. The port number of the UDP socket used by FSP client utilities.
  1726. You may pick any number not currently used for other purposes.
  1727. The main reason of defining this number is to ensure mutual
  1728. exclusion between client utilities accessing the same FSP database.
  1729. X.TP
  1730. X.B FSP_DIR
  1731. The current working directory of the client in the FSP database.
  1732. The root of the database is /.
  1733. X.TP
  1734. X.B FSP_TRACE
  1735. If this variable is set,   
  1736. X.B fput
  1737. will display the number of kilo-byte blocks transfered as transfer 
  1738. progresses. 
  1739. X.SH "SEE ALSO"
  1740. X.PD
  1741. fcatcmd(1), fcdcmd(1), fgetcmd(1), flscmd(1), fmkdir(1),
  1742. fprocmd(1), fput(1), frmcmd(1), frmdircmd(1), fver(1), fspd(1)
  1743. END_OF_FILE
  1744. if test 1197 -ne `wc -c <'fput.1'`; then
  1745.     echo shar: \"'fput.1'\" unpacked with wrong size!
  1746. fi
  1747. # end of 'fput.1'
  1748. fi
  1749. if test -f 'fput.c' -a "${1}" != "-c" ; then 
  1750.   echo shar: Will not clobber existing file \"'fput.c'\"
  1751. else
  1752. echo shar: Extracting \"'fput.c'\" \(1212 characters\)
  1753. sed "s/^X//" >'fput.c' <<'END_OF_FILE'
  1754. X    /*********************************************************************\
  1755. X    *  Copyright (c) 1991 by Wen-King Su (wen-king@vlsi.cs.caltech.edu)   *
  1756. X    *                                                                     *
  1757. X    *  You may copy or modify this file in any manner you wish, provided  *
  1758. X    *  that this notice is always included, and that you hold the author  *
  1759. X    *  harmless for any loss or damage resulting from the installation or *
  1760. X    *  use of this software.                                              *
  1761. X    \*********************************************************************/
  1762. X
  1763. X#include "client_def.h"
  1764. X
  1765. main(argc,argv,envp)
  1766. X    int argc;
  1767. X    char **argv,**envp;
  1768. X{
  1769. X    env_client();
  1770. X    while(*++argv) put_file(*argv);
  1771. X    client_done();
  1772. X
  1773. X    exit(0);
  1774. X}
  1775. X
  1776. put_file(path)
  1777. X    char *path;
  1778. X{
  1779. X    struct stat sb;
  1780. X    char *name, *t2;
  1781. X    FILE *fp;
  1782. X
  1783. X    if(stat(path,&sb) != 0) { perror(path); return; }
  1784. X    if(!(S_IFREG & sb.st_mode)) { fprintf(stderr,"%s: not a file\n",path);
  1785. X                return; }
  1786. X
  1787. X    for(name = t2 = path; *t2; t2++) if(*t2 == '/') name = t2 + 1;
  1788. X
  1789. X    if(fp = fopen(path,"r"))
  1790. X    {
  1791. X    util_upload(name,fp);
  1792. X    fclose(fp);
  1793. X
  1794. X    } else fprintf(stderr,"Cannot read %s\n",path);
  1795. X}
  1796. END_OF_FILE
  1797. if test 1212 -ne `wc -c <'fput.c'`; then
  1798.     echo shar: \"'fput.c'\" unpacked with wrong size!
  1799. fi
  1800. # end of 'fput.c'
  1801. fi
  1802. if test -f 'frmcmd.1' -a "${1}" != "-c" ; then 
  1803.   echo shar: Will not clobber existing file \"'frmcmd.1'\"
  1804. else
  1805. echo shar: Extracting \"'frmcmd.1'\" \(1425 characters\)
  1806. sed "s/^X//" >'frmcmd.1' <<'END_OF_FILE'
  1807. X.TH FRM 1 "8 December 1991"
  1808. X.SH NAME
  1809. frmcmd, frm \- remove files from the FSP database
  1810. X.SH SYNOPSIS
  1811. X.B frmcmd
  1812. X.I filename
  1813. X\&.\|.\|.
  1814. X.LP
  1815. X.B frm
  1816. X.I filename
  1817. X\&.\|.\|.
  1818. X.SH DESCRIPTION
  1819. X.LP
  1820. X.B frmcmd
  1821. deletes the named files from the FSP database.
  1822. X.B frmcmd
  1823. will perform
  1824. X.B csh
  1825. file name globbing based on file and directory information
  1826. obtained from the FSP database.
  1827. X.LP
  1828. Since user's command shells generally cannot do the proper globbing for
  1829. this program, it is recommended that user defines a shell alias or
  1830. fucntion to turns off command shell globbing before running this program.
  1831. X.B csh
  1832. example:
  1833. X.LP
  1834. X.nf
  1835. alias frm \e(set noglob\e; exec frmcmd \e!\e*\e)
  1836. X.fi
  1837. X.SH ENVIRONMENT
  1838. X.LP
  1839. The following variables associate this program with a FSP database:
  1840. X.TP
  1841. X.B FSP_HOST
  1842. The name or internet number of the machine with the FSP server.
  1843. X.TP
  1844. X.B FSP_PORT
  1845. The port number of the UDP socket used by the FSP server.
  1846. X.TP
  1847. X.B FSP_LOCALPORT
  1848. The port number of the UDP socket used by FSP client utilities.
  1849. You may pick any number not currently used for other purposes.
  1850. The main reason of defining this number is to ensure mutual
  1851. exclusion between client utilities accessing the same FSP database.
  1852. X.TP
  1853. X.B FSP_DIR
  1854. The current working directory of the client in the FSP database.
  1855. The root of the database is /.
  1856. X.SH "SEE ALSO"
  1857. X.PD
  1858. fcatcmd(1), fcdcmd(1), fgetcmd(1), flscmd(1), fmkdir(1),
  1859. fprocmd(1), fput(1), frmcmd(1), frmdircmd(1), fver(1), fspd(1)
  1860. END_OF_FILE
  1861. if test 1425 -ne `wc -c <'frmcmd.1'`; then
  1862.     echo shar: \"'frmcmd.1'\" unpacked with wrong size!
  1863. fi
  1864. # end of 'frmcmd.1'
  1865. fi
  1866. if test -f 'frmcmd.c' -a "${1}" != "-c" ; then 
  1867.   echo shar: Will not clobber existing file \"'frmcmd.c'\"
  1868. else
  1869. echo shar: Extracting \"'frmcmd.c'\" \(1230 characters\)
  1870. sed "s/^X//" >'frmcmd.c' <<'END_OF_FILE'
  1871. X    /*********************************************************************\
  1872. X    *  Copyright (c) 1991 by Wen-King Su (wen-king@vlsi.cs.caltech.edu)   *
  1873. X    *                                                                     *
  1874. X    *  You may copy or modify this file in any manner you wish, provided  *
  1875. X    *  that this notice is always included, and that you hold the author  *
  1876. X    *  harmless for any loss or damage resulting from the installation or *
  1877. X    *  use of this software.                                              *
  1878. X    \*********************************************************************/
  1879. X
  1880. X#include "client_def.h"
  1881. X
  1882. extern char **glob(), *util_abs_path();
  1883. X
  1884. main(argc,argv,envp)
  1885. X    int argc;
  1886. X    char **argv,**envp;
  1887. X{
  1888. X    char **av, *av2[2];
  1889. X
  1890. X    env_client();
  1891. X
  1892. X    while(*++argv)
  1893. X    {
  1894. X    if(!(av = glob(*argv))) { av = av2; av2[0] = *argv; av2[1] = 0; }
  1895. X    while(*av) remove_it(*av++);
  1896. X    }
  1897. X
  1898. X    client_done();
  1899. X
  1900. X    exit(0);
  1901. X}
  1902. X
  1903. remove_it(p)
  1904. X    char *p;
  1905. X{
  1906. X    char *op;
  1907. X    UBUF *ub;
  1908. X
  1909. X    op = util_abs_path(p);
  1910. X
  1911. X    ub = client_interact(CC_DEL_FILE,0L, strlen(op),op+1, 0,NULLP);
  1912. X
  1913. X    if(ub->cmd == CC_ERR)
  1914. X    {
  1915. X    fprintf(stderr,"Can't remove %s: %s\n",p,ub->buf);
  1916. X    free(op); return(-1);
  1917. X    }
  1918. X
  1919. X    return(0);
  1920. X}
  1921. END_OF_FILE
  1922. if test 1230 -ne `wc -c <'frmcmd.c'`; then
  1923.     echo shar: \"'frmcmd.c'\" unpacked with wrong size!
  1924. fi
  1925. # end of 'frmcmd.c'
  1926. fi
  1927. if test -f 'frmdircmd.1' -a "${1}" != "-c" ; then 
  1928.   echo shar: Will not clobber existing file \"'frmdircmd.1'\"
  1929. else
  1930. echo shar: Extracting \"'frmdircmd.1'\" \(1466 characters\)
  1931. sed "s/^X//" >'frmdircmd.1' <<'END_OF_FILE'
  1932. X.TH FRMDIR 1 "8 December 1991"
  1933. X.SH NAME
  1934. frmdircmd, frmdir \- remove directories from the FSP database
  1935. X.SH SYNOPSIS
  1936. X.B frmdircmd
  1937. X.I directory
  1938. X\&.\|.\|.
  1939. X.LP
  1940. X.B frmdir
  1941. X.I directory
  1942. X\&.\|.\|.
  1943. X.SH DESCRIPTION
  1944. X.LP
  1945. X.B frmdircmd
  1946. deletes the named directories from the FSP database.
  1947. X.B frmdircmd
  1948. will perform
  1949. X.B csh
  1950. file name globbing based on file and directory information
  1951. obtained from the FSP database.
  1952. X.LP
  1953. Since user's command shells generally cannot do the proper globbing for
  1954. this program, it is recommended that user defines a shell alias or
  1955. fucntion to turns off command shell globbing before running this program.
  1956. X.B csh
  1957. example:
  1958. X.LP
  1959. X.nf
  1960. alias frmdir \e(set noglob\e; exec frmdircmd \e!\e*\e)
  1961. X.fi
  1962. X.SH ENVIRONMENT
  1963. X.LP
  1964. The following variables associate this program with a FSP database:
  1965. X.TP
  1966. X.B FSP_HOST
  1967. The name or internet number of the machine with the FSP server.
  1968. X.TP
  1969. X.B FSP_PORT
  1970. The port number of the UDP socket used by the FSP server.
  1971. X.TP
  1972. X.B FSP_LOCALPORT
  1973. The port number of the UDP socket used by FSP client utilities.
  1974. You may pick any number not currently used for other purposes.
  1975. The main reason of defining this number is to ensure mutual
  1976. exclusion between client utilities accessing the same FSP database.
  1977. X.TP
  1978. X.B FSP_DIR
  1979. The current working directory of the client in the FSP database.
  1980. The root of the database is /.
  1981. X.SH "SEE ALSO"
  1982. X.PD
  1983. fcatcmd(1), fcdcmd(1), fgetcmd(1), flscmd(1), fmkdir(1),
  1984. fprocmd(1), fput(1), frmcmd(1), frmdircmd(1), fver(1), fspd(1)
  1985. END_OF_FILE
  1986. if test 1466 -ne `wc -c <'frmdircmd.1'`; then
  1987.     echo shar: \"'frmdircmd.1'\" unpacked with wrong size!
  1988. fi
  1989. # end of 'frmdircmd.1'
  1990. fi
  1991. if test -f 'frmdircmd.c' -a "${1}" != "-c" ; then 
  1992.   echo shar: Will not clobber existing file \"'frmdircmd.c'\"
  1993. else
  1994. echo shar: Extracting \"'frmdircmd.c'\" \(1229 characters\)
  1995. sed "s/^X//" >'frmdircmd.c' <<'END_OF_FILE'
  1996. X    /*********************************************************************\
  1997. X    *  Copyright (c) 1991 by Wen-King Su (wen-king@vlsi.cs.caltech.edu)   *
  1998. X    *                                                                     *
  1999. X    *  You may copy or modify this file in any manner you wish, provided  *
  2000. X    *  that this notice is always included, and that you hold the author  *
  2001. X    *  harmless for any loss or damage resulting from the installation or *
  2002. X    *  use of this software.                                              *
  2003. X    \*********************************************************************/
  2004. X
  2005. X#include "client_def.h"
  2006. X
  2007. extern char **glob(), *util_abs_path();
  2008. X
  2009. main(argc,argv,envp)
  2010. X    int argc;
  2011. X    char **argv,**envp;
  2012. X{
  2013. X    char **av, *av2[2];
  2014. X
  2015. X    env_client();
  2016. X
  2017. X    while(*++argv)
  2018. X    {
  2019. X    if(!(av = glob(*argv))) { av = av2; av2[0] = *argv; av2[1] = 0; }
  2020. X    while(*av) remove_it(*av++);
  2021. X    }
  2022. X
  2023. X    client_done();
  2024. X
  2025. X    exit(0);
  2026. X}
  2027. X
  2028. remove_it(p)
  2029. X    char *p;
  2030. X{
  2031. X    char *op;
  2032. X    UBUF *ub;
  2033. X
  2034. X    op = util_abs_path(p);
  2035. X
  2036. X    ub = client_interact(CC_DEL_DIR,0L, strlen(op),op+1, 0,NULLP);
  2037. X
  2038. X    if(ub->cmd == CC_ERR)
  2039. X    {
  2040. X    fprintf(stderr,"Can't remove %s: %s\n",p,ub->buf);
  2041. X    free(op); return(-1);
  2042. X    }
  2043. X
  2044. X    return(0);
  2045. X}
  2046. END_OF_FILE
  2047. if test 1229 -ne `wc -c <'frmdircmd.c'`; then
  2048.     echo shar: \"'frmdircmd.c'\" unpacked with wrong size!
  2049. fi
  2050. # end of 'frmdircmd.c'
  2051. fi
  2052. if test -f 'fspd.1' -a "${1}" != "-c" ; then 
  2053.   echo shar: Will not clobber existing file \"'fspd.1'\"
  2054. else
  2055. echo shar: Extracting \"'fspd.1'\" \(1610 characters\)
  2056. sed "s/^X//" >'fspd.1' <<'END_OF_FILE'
  2057. X.TH FSPD 1 "8 December 1991"
  2058. X.SH NAME
  2059. fspd, in.fspd \- server for the FSP database
  2060. X.SH SYNOPSIS
  2061. X.B fspd
  2062. X[
  2063. X.B -h path
  2064. X.B |
  2065. X.B -p port
  2066. X.B |
  2067. X.B -u uid
  2068. X]
  2069. X.LP
  2070. X.B in.fspd
  2071. X.SH DESCRIPTION
  2072. X.B fspd
  2073. is the server for an anonymous-ftp style archive called FSP. The main
  2074. features of this service are: connection-less model, communication
  2075. robustness, server resource protection, inter-client protection, and user
  2076. friendly interface. Please read the INFO file bundled with the FSP source
  2077. for more information. 
  2078. X.LP
  2079. X.SH FILES
  2080. X.PD 0
  2081. X.TP 20
  2082. X.B .OWN.XXXXXXXX
  2083. Used to indicate the ownership of a directory.  If this file is
  2084. present in a directory, the directory is owned by the machine whose
  2085. inet number is XXXXXXXX when printed as an 8-digit hex number.
  2086. X
  2087. X.TP
  2088. X.B .FSP_NO_DEL
  2089. XExistence of this file in a directory prevents non-owner machines
  2090. from deleting items from this directory.
  2091. X
  2092. X.TP
  2093. X.B .FSP_NO_ADD
  2094. XExistence of this file in a directory prevents non-owner machines
  2095. from adding items to this directory.
  2096. X
  2097. X.TP
  2098. X.B .TMP.XXXXXXXX
  2099. Transient temporary file in the top FSP directory used for file
  2100. uploading.
  2101. X
  2102. X.TP
  2103. X.B .HTAB_DUMP
  2104. A file created in the top directory when
  2105. X.B fspd
  2106. receives an alarm signal.  It contains a listing of the active
  2107. clients in
  2108. X.B fspd's
  2109. client table.
  2110. X
  2111. X.TP
  2112. X.B .ROGUE_HOSTS
  2113. A file containing a list of inet numbers in the normal 4-part format.
  2114. X.B fspd
  2115. will not respond to messages from machines named in this file.
  2116. X
  2117. X.TP
  2118. X.B .FSP_CONTENT
  2119. XFile used to cache directory listing.
  2120. X
  2121. X.SH "SEE ALSO"
  2122. X.PD
  2123. fcatcmd(1), fcdcmd(1), fgetcmd(1), flscmd(1), fmkdir(1),
  2124. fprocmd(1), fput(1), frmcmd(1), frmdircmd(1), fver(1), fspd(1)
  2125. END_OF_FILE
  2126. if test 1610 -ne `wc -c <'fspd.1'`; then
  2127.     echo shar: \"'fspd.1'\" unpacked with wrong size!
  2128. fi
  2129. # end of 'fspd.1'
  2130. fi
  2131. if test -f 'fver.1' -a "${1}" != "-c" ; then 
  2132.   echo shar: Will not clobber existing file \"'fver.1'\"
  2133. else
  2134. echo shar: Extracting \"'fver.1'\" \(974 characters\)
  2135. sed "s/^X//" >'fver.1' <<'END_OF_FILE'
  2136. X.TH FVER 1 "8 December 1991"
  2137. X.SH NAME
  2138. fver \- displays the version number string of the FSP database
  2139. X.SH SYNOPSIS
  2140. X.B fver
  2141. X.SH DESCRIPTION
  2142. X.LP
  2143. X.B fver
  2144. displays the version number string of the FSP database.
  2145. X.SH ENVIRONMENT
  2146. X.LP
  2147. The following variables associate this program with a FSP database:
  2148. X.TP
  2149. X.B FSP_HOST
  2150. The name or internet number of the machine with the FSP server.
  2151. X.TP
  2152. X.B FSP_PORT
  2153. The port number of the UDP socket used by the FSP server.
  2154. X.TP
  2155. X.B FSP_LOCALPORT
  2156. The port number of the UDP socket used by FSP client utilities.
  2157. You may pick any number not currently used for other purposes.
  2158. The main reason of defining this number is to ensure mutual
  2159. exclusion between client utilities accessing the same FSP database.
  2160. X.TP
  2161. X.B FSP_DIR
  2162. The current working directory of the client in the FSP database.
  2163. The root of the database is /.
  2164. X.SH "SEE ALSO"
  2165. X.PD
  2166. fcatcmd(1), fcdcmd(1), fgetcmd(1), flscmd(1), fmkdir(1),
  2167. fprocmd(1), fput(1), frmcmd(1), frmdircmd(1), fver(1), fspd(1)
  2168. END_OF_FILE
  2169. if test 974 -ne `wc -c <'fver.1'`; then
  2170.     echo shar: \"'fver.1'\" unpacked with wrong size!
  2171. fi
  2172. # end of 'fver.1'
  2173. fi
  2174. if test -f 'fver.c' -a "${1}" != "-c" ; then 
  2175.   echo shar: Will not clobber existing file \"'fver.c'\"
  2176. else
  2177. echo shar: Extracting \"'fver.c'\" \(830 characters\)
  2178. sed "s/^X//" >'fver.c' <<'END_OF_FILE'
  2179. X    /*********************************************************************\
  2180. X    *  Copyright (c) 1991 by Wen-King Su (wen-king@vlsi.cs.caltech.edu)   *
  2181. X    *                                                                     *
  2182. X    *  You may copy or modify this file in any manner you wish, provided  *
  2183. X    *  that this notice is always included, and that you hold the author  *
  2184. X    *  harmless for any loss or damage resulting from the installation or *
  2185. X    *  use of this software.                                              *
  2186. X    \*********************************************************************/
  2187. X
  2188. X#include <stdio.h>
  2189. X#include "client_def.h"
  2190. X
  2191. main()
  2192. X{
  2193. X    UBUF *ub;
  2194. X
  2195. X    env_client();
  2196. X    ub = client_interact(CC_VERSION,0L, 0,NULLP, 0,NULLP);
  2197. X    printf("FSP version: %s\n",ub->buf);
  2198. X    client_done();
  2199. X
  2200. X    exit(0);
  2201. X}
  2202. END_OF_FILE
  2203. if test 830 -ne `wc -c <'fver.c'`; then
  2204.     echo shar: \"'fver.c'\" unpacked with wrong size!
  2205. fi
  2206. # end of 'fver.c'
  2207. fi
  2208. if test -f 'server_def.h' -a "${1}" != "-c" ; then 
  2209.   echo shar: Will not clobber existing file \"'server_def.h'\"
  2210. else
  2211. echo shar: Extracting \"'server_def.h'\" \(1801 characters\)
  2212. sed "s/^X//" >'server_def.h' <<'END_OF_FILE'
  2213. X    /*********************************************************************\
  2214. X    *  Copyright (c) 1991 by Wen-King Su (wen-king@vlsi.cs.caltech.edu)   *
  2215. X    *                                                                     *
  2216. X    *  You may copy or modify this file in any manner you wish, provided  *
  2217. X    *  that this notice is always included, and that you hold the author  *
  2218. X    *  harmless for any loss or damage resulting from the installation or *
  2219. X    *  use of this software.                                              *
  2220. X    \*********************************************************************/
  2221. X
  2222. X#include "common_def.h"
  2223. X
  2224. X/****************************************************************************
  2225. X*  HTAB is structure for storing client information for one client machine.
  2226. X*  They makes it easy to reuse regular unix tool's source for new purposes.
  2227. X****************************************************************************/
  2228. X
  2229. typedef struct HTAB HTAB;
  2230. X
  2231. struct HTAB {    unsigned long    inet_num;    /* inet number of client     */
  2232. X        unsigned long   last_acc;    /* last sucessful access time*/
  2233. X        unsigned short    next_key;    /* next key client should use*/
  2234. X        unsigned short    last_key;    /* previous key client used  */
  2235. X        unsigned short   acc_cnt;    /* number of successful acc  */
  2236. X        unsigned short  active:1;       /* session continuing.         */
  2237. X        unsigned short inhibit:1; };    /* deny access permission.   */
  2238. X
  2239. extern init_htab();
  2240. extern HTAB *find_host();
  2241. extern char *check_path();
  2242. X
  2243. extern char *server_make_dir();
  2244. extern char *server_del_dir();
  2245. extern char *server_del_file();
  2246. extern char *server_get_dir();
  2247. extern char *server_get_file();
  2248. extern char *server_get_pro();
  2249. extern char *server_set_pro();
  2250. extern char *server_up_load();
  2251. extern char *server_install();
  2252. X
  2253. extern int dbug;
  2254. extern char *home_dir;
  2255. END_OF_FILE
  2256. if test 1801 -ne `wc -c <'server_def.h'`; then
  2257.     echo shar: \"'server_def.h'\" unpacked with wrong size!
  2258. fi
  2259. # end of 'server_def.h'
  2260. fi
  2261. if test -f 'setup' -a "${1}" != "-c" ; then 
  2262.   echo shar: Will not clobber existing file \"'setup'\"
  2263. else
  2264. echo shar: Extracting \"'setup'\" \(626 characters\)
  2265. sed "s/^X//" >'setup' <<'END_OF_FILE'
  2266. X
  2267. X# Sample csh initialization file.
  2268. X
  2269. setenv FSP_PORT 21
  2270. setenv FSP_LOCALPORT 4334
  2271. setenv FSP_HOST 131.215.131.97
  2272. setenv FSP_DIR  /
  2273. setenv FSP_TRACE
  2274. X
  2275. alias fcd setenv FSP_DIR \`\(set noglob\; exec fcdcmd \!\*\)\`
  2276. alias fls    \(set noglob\; exec flscmd    \!\*\)
  2277. alias fget   \(set noglob\; exec fgetcmd   \!\*\)
  2278. alias fcat   \(set noglob\; exec fcatcmd   \!\*\)
  2279. alias fmore  \(set noglob\; exec fcatcmd   \!\* \| less \)
  2280. alias frm    \(set noglob\; exec frmcmd    \!\*\)
  2281. alias frmdir \(set noglob\; exec frmdircmd \!\*\)
  2282. alias fpro   \(set noglob\; exec fprocmd   \!\*\)
  2283. alias fpwd echo \$FSP_DIR on \$FSP_HOST port \$FSP_PORT
  2284. END_OF_FILE
  2285. if test 626 -ne `wc -c <'setup'`; then
  2286.     echo shar: \"'setup'\" unpacked with wrong size!
  2287. fi
  2288. # end of 'setup'
  2289. fi
  2290. echo shar: End of archive 1 \(of 3\).
  2291. cp /dev/null ark1isdone
  2292. MISSING=""
  2293. for I in 1 2 3 ; do
  2294.     if test ! -f ark${I}isdone ; then
  2295.     MISSING="${MISSING} ${I}"
  2296.     fi
  2297. done
  2298. if test "${MISSING}" = "" ; then
  2299.     echo You have unpacked all 3 archives.
  2300.     rm -f ark[1-9]isdone
  2301. else
  2302.     echo You still need to unpack the following archives:
  2303.     echo "        " ${MISSING}
  2304. fi
  2305. ##  End of shell archive.
  2306. exit 0
  2307.